﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WPFServices.ViewModels.AI;

namespace WPFServices.Views.DomainViews.AI
{
    /// <summary>
    /// ChatView.xaml 的交互逻辑
    /// </summary>
    public partial class ChatView : UserControl
    {
        public ChatView()
        {
            InitializeComponent();
            DataContext = new ChatViewModel();
        }

        private void InputTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (Keyboard.Modifiers == ModifierKeys.Shift)
                {
                    // Shift+Enter = 换行，保持默认行为
                    return;
                }
                else
                {
                    // 单独Enter = 发送消息
                    e.Handled = true; // 阻止默认换行行为

                    if (DataContext is ChatViewModel viewModel && viewModel.SendCommand.CanExecute(null))
                    {
                        viewModel.SendCommand.Execute(null);
                    }
                }
            }
        }
    }
}